package com.kt.app

import android.os.Bundle
import android.widget.TextView
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Devices
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import com.kt.app.models.entity.ScaffoldSample
import com.kt.app.ui.components.PlusText
import com.kt.app.ui.components.ProgressIndicatorSample
import com.kt.app.ui.components.TextPlus
import com.kt.app.ui.theme.KtappTheme

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
//        enableEdgeToEdge()
        setContent {
//            MainFrame()
//            TextSample()
//            TextPlus()
//            ProgressIndicatorSample()
            ScaffoldSample()
        }
        setContentView(R.layout.layout)

        val composeView = findViewById<ComposeView>(R.id.compose_view) // andoird view 里面设置composeView
        composeView.setContent { // ComposeView 里面设置组件
            Column {
                TextPlus()
                AndroidView(factory = { // ComposeView设置composeView AndroidView
                    TextView(it)
                }){
                    it.apply { text = "Hello World" }
                }
            }

        }

    }
}

@Composable
fun TextSample(){
        Text(
            text = "Hello World",
            modifier = Modifier
                .fillMaxSize()
                .padding(14.dp),
            style = TextStyle(
                background = Color.Green
            )
        )
}

@Composable
@Preview(showBackground = true, backgroundColor = 0xFFF0EAE2, device = Devices.NEXUS_6, showSystemUi = true)
fun DefaultPreview(){
    KtappTheme { TextSample() }

}


@Composable
fun MainFrame() {
    
}

@Preview
@Composable
fun MainFramePreview() {

}